package lesson04;

/**
 * 双色球类
 */
public class Ball {
    /**
     * 双色球产生的值
     */
    private int value;
    /**
     * 红球（red）或蓝球（blue）的类型
     */
    private String type;
    public Ball(){}
    public Ball(int value){
        this.value = value;
    }
    public Ball(String type){
        this.type = type;
        this.generateNumber();
    }
    /**
     * 随机产生双色球的值
     */
    public void generateNumber(){
        if(type.equals("red")){
            this.value = (int)(Math.random() * 33) + 1;
        }else if(type.equals("blue")){
            this.value = (int)(Math.random() * 16) + 1;
        }

    }
    public int getValue(){
        return this.value;
    }
    public void setValue(int value){
        this.value = value;
    }

    public static void main(String[] args) {
        Ball redBall = new Ball("red");
        Ball blueBall = new Ball("blue");
        System.out.println(redBall.getValue());
        System.out.println(blueBall.getValue());
    }
}
